Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update QPSG logic #2066

Merged

Conversation

KodiaqQ
Copy link
Collaborator

@KodiaqQ KodiaqQ commented Aug 18, 2023

Changes

  • Updated QPSG logic for Embedding quantization case

Reason for changes

  • Proper quantization logic for QPSG in the specific case

Related tickets

Tests

  • Updated tests/common/quantization/test_quantizer_propagation_graph.py

@KodiaqQ KodiaqQ requested a review from vshampor August 18, 2023 16:20
@KodiaqQ KodiaqQ requested a review from a team as a code owner August 18, 2023 16:20
@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch NNCF Common Pull request that updates NNCF Common labels Aug 18, 2023
@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Merging #2066 (6ecd962) into develop (a1074e7) will increase coverage by 3.14%.
Report is 2 commits behind head on develop.
The diff coverage is 80.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2066      +/-   ##
===========================================
+ Coverage    32.93%   36.08%   +3.14%     
===========================================
  Files          476      476              
  Lines        42391    42408      +17     
===========================================
+ Hits         13961    15302    +1341     
+ Misses       28430    27106    -1324     
Files Changed Coverage Δ
nncf/quantization/algorithms/algorithm.py 100.00% <ø> (ø)
nncf/torch/model_transformer.py 35.44% <0.00%> (ø)
nncf/torch/model_creation.py 36.26% <33.33%> (-0.10%) ⬇️
...common/quantization/quantizer_propagation/graph.py 84.49% <100.00%> (+11.95%) ⬆️
...quantization/algorithms/post_training/algorithm.py 76.85% <100.00%> (+0.66%) ⬆️

... and 42 files with indirect coverage changes

Comment on lines +1436 to +1444
act_qconfig_extend_list = []
for act_qconfig in activation_qconfig_options:
if act_qconfig.signedness_to_force is None:
for signedness_to_force_position in [True, False]:
act_qconfig_updated = deepcopy(act_qconfig)
act_qconfig_updated.signedness_to_force = signedness_to_force_position
act_qconfig_extend_list.append(act_qconfig_updated)
act_qconfig_extend_list += activation_qconfig_options
return [qconf for qconf in weight_qconfig_options if qconf in act_qconfig_extend_list]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that this logic covers the following case:
let weight_qconfig_options = [(*partial_configuration*, signedness_to_force=None), ]

let activation_qconfig_options = [(*same_partial_configuration*, signedness_to_force=None), ]

then the intersection should be:
intersection == [(*same_partial_configuration*, signedness_to_force=None),]

and currently it looks like your logic will produce the following instead:
intersection == [(*same_partial_configuration*, signedness_to_force=True), (*same_partial_configuration*, signedness_to_force=False)]

While we are not likely to encounter this case realistically, I think that the current behaviour in this case would be confusing.

Copy link
Collaborator Author

@KodiaqQ KodiaqQ Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, for the:

  • weight_qconfig_options = [(*partial_configuration*, signedness_to_force=None), ] and
  • activation_qconfig_options = [(*same_partial_configuration*, signedness_to_force=None), ]

the intersection would be:
[(*same_partial_configuration*, signedness_to_force=None), ].
This is because we save the original configuration of the activations and just add the modifications for the originals.
See 1443 line.

Added test case for that.

@KodiaqQ KodiaqQ force-pushed the nm/update_qpsg_for_embeddings branch from 9c53dd6 to a46cef4 Compare August 18, 2023 16:52
@github-actions github-actions bot added the NNCF ONNX Pull requests that updates NNCF ONNX label Aug 18, 2023
@KodiaqQ KodiaqQ requested a review from vshampor August 18, 2023 17:07
@github-actions github-actions bot added the NNCF OpenVINO Pull requests that updates NNCF OpenVINO label Aug 18, 2023
@KodiaqQ
Copy link
Collaborator Author

KodiaqQ commented Aug 19, 2023

run pytorch pre-commit tests

@vshampor vshampor merged commit 23e1b87 into openvinotoolkit:develop Aug 21, 2023
6 checks passed
KodiaqQ added a commit to KodiaqQ/nncf that referenced this pull request Aug 21, 2023
### Changes

- Updated QPSG logic for Embedding quantization case

### Reason for changes

- Proper quantization logic for QPSG in the specific case

### Related tickets

- Post-merge of openvinotoolkit#2040 (CVS-113692)

### Tests

- Updated
`tests/common/quantization/test_quantizer_propagation_graph.py`

(cherry picked from commit 23e1b87)
vshampor pushed a commit that referenced this pull request Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NNCF Common Pull request that updates NNCF Common NNCF ONNX Pull requests that updates NNCF ONNX NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PT Pull requests that updates NNCF PyTorch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants